package com.itqf.proxy.dynamic_proxy1;

import com.itqf.proxy.dynamic_proxy1.factoy.MyProxyFactory;
import com.itqf.proxy.dynamic_proxy1.impl.GoodsServiceImpl;
import com.itqf.proxy.dynamic_proxy1.impl.OrderServiceImpl;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/11/10
 * @Time: 上午11:07
 */
public class TestJdk {

    public  static  void  main(String[]args){

        //1,创建被代理对象
        OrderService orderService  = new OrderServiceImpl();//没有增强  目标类
        //2.得到代理对象
        OrderService proxyOrderService =  MyProxyFactory.createProxyFactory(orderService);

        proxyOrderService.updateOrder();
        proxyOrderService.addOrder();

        System.out.println("--------------------");
        //被代理对象   只有核心业务  没有事务（辅助代码）
        GoodsService goodsService = new GoodsServiceImpl();

//        goodsService.addGoods("张三");
//        System.out.println(goodsService.updateGoods());
        //得到代理对象

        GoodsService proxyGoodsService = MyProxyFactory.createProxyFactory(goodsService);
        proxyGoodsService.addGoods("张三");
        System.out.println(proxyGoodsService.updateGoods());




    }
}
